package org.pixelami.twisted.spread.jelly
{
	public class SecurityOptions
	{
		public function SecurityOptions()
		{
		}
		
		/*
		class SecurityOptions:
	    """
	    This will by default disallow everything, except for 'none'.
	    """
	
	    basicTypes = ["dictionary", "list", "tuple",
	                  "reference", "dereference", "unpersistable",
	                  "persistent", "long_int", "long", "dict"]
	
	    def __init__(self):
	        """SecurityOptions()
	        Initialize.
	        """
	        # I don't believe any of these types can ever pose a security hazard,
	        # except perhaps "reference"...
	        self.allowedTypes = {"None": 1,
	                             "bool": 1,
	                             "boolean": 1,
	                             "string": 1,
	                             "str": 1,
	                             "int": 1,
	                             "float": 1,
	                             "datetime": 1,
	                             "time": 1,
	                             "date": 1,
	                             "timedelta": 1,
	                             "NoneType": 1}
	        if hasattr(types, 'UnicodeType'):
	            self.allowedTypes['unicode'] = 1
	        self.allowedModules = {}
	        self.allowedClasses = {}
	
	    def allowBasicTypes(self):
	        """SecurityOptions.allowBasicTypes()
	        Allow all `basic' types.  (Dictionary and list.  Int, string, and float are implicitly allowed.)
	        """
	        self.allowTypes(*self.basicTypes)
	
	    def allowTypes(self, *types):
	        """SecurityOptions.allowTypes(typeString): Allow a particular type, by its name.
	        """
	        for typ in types:
	            if not isinstance(typ, str):
	                typ = qual(typ)
	            self.allowedTypes[typ] = 1
	
	    def allowInstancesOf(self, *classes):
	        """SecurityOptions.allowInstances(klass, klass, ...): allow instances
	        of the specified classes
	
	        This will also allow the 'instance', 'class' (renamed 'classobj' in
	        Python 2.3), and 'module' types, as well as basic types.
	        """
	        self.allowBasicTypes()
	        self.allowTypes("instance", "class", "classobj", "module")
	        for klass in classes:
	            self.allowTypes(qual(klass))
	            self.allowModules(klass.__module__)
	            self.allowedClasses[klass] = 1
	
	    def allowModules(self, *modules):
	        """SecurityOptions.allowModules(module, module, ...): allow modules by name
	        This will also allow the 'module' type.
	        """
	        for module in modules:
	            if type(module) == types.ModuleType:
	                module = module.__name__
	            self.allowedModules[module] = 1
	
	    def isModuleAllowed(self, moduleName):
	        """SecurityOptions.isModuleAllowed(moduleName) -> boolean
	        returns 1 if a module by that name is allowed, 0 otherwise
	        """
	        return self.allowedModules.has_key(moduleName)
	
	    def isClassAllowed(self, klass):
	        """SecurityOptions.isClassAllowed(class) -> boolean
	        Assumes the module has already been allowed.  Returns 1 if the given
	        class is allowed, 0 otherwise.
	        """
	        return self.allowedClasses.has_key(klass)
	
	    def isTypeAllowed(self, typeName):
	        """SecurityOptions.isTypeAllowed(typeName) -> boolean
	        Returns 1 if the given type is allowed, 0 otherwise.
	        """
	        return (self.allowedTypes.has_key(typeName) or
	                '.' in typeName)
        */

	}
}